#include <QApplication>
#include <QDateTime>
#include <QDebug>
#include <QtConcurrent>
#include <qapplication.h>
#include <qmetaobject.h>

class Controller  : public QObject
{
    Q_OBJECT
public:
    Controller()
    {
        QtConcurrent::run(this, &Controller::doSomething);
    }
private slots:
    void doSomething()
    {
        qDebug() << "Doing something at " << QDateTime::currentDateTime();
        quit(); // 没有

        // 请求完成后回到主线程执行
        QMetaObject::invokeMethod(this, &Controller::quit, Qt::QueuedConnection);
    }

    void quit() {
        qApp->quit();
    };
};

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    Controller c;
    return a.exec();
}

#include "main.moc"
